/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.zhaojiu.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.persistence.CascadeType;
import javax.validation.constraints.*;
import javax.persistence.Entity;
import javax.persistence.Table;

import me.zhengjie.base.BaseEntity;
import org.hibernate.annotations.*;
import java.sql.Timestamp;
import java.io.Serializable;

/**
* @website https://el-admin.vip
* @description /
* @author Jiayin Wei
* @date 2021-12-09
**/
@Entity
@Data
@Table(name="zj_student")
public class Student extends BaseEntity implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "student_id")
    @ApiModelProperty(value = "学生ID")
    private Long studentId;

    @Column(name = "user_id")
    @ApiModelProperty(value = "用户ID")
    private Long userId;

    @Column(name = "name",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "姓名")
    private String name;

    @Column(name = "class_id")
    @ApiModelProperty(value = "班级ID")
    private Long classId;

    @ManyToOne
    @JoinColumn(name = "class_id", referencedColumnName = "class_id", insertable = false, updatable = false)
    @ApiModelProperty(value = "班级")
    private Class classModel;

    @Column(name = "school")
    @ApiModelProperty(value = "学校")
    private String school;

    @Column(name = "college_id")
    @ApiModelProperty(value = "学院ID")
    private Long collegeId;

    @ManyToOne
    @JoinColumn(name = "college_id", referencedColumnName = "dept_id", insertable = false, updatable = false)
    @ApiModelProperty(value = "学院")
    private Department college;

    @Column(name = "major_depart_id")
    @ApiModelProperty(value = "专业ID")
    private Long majorDepartId;

    @ManyToOne
    @JoinColumn(name = "major_depart_id", referencedColumnName = "dept_id", insertable = false, updatable = false)
    @ApiModelProperty(value = "专业")
    private Department majorDepart;

    @Column(name = "phone")
    @ApiModelProperty(value = "联系电话")
    private String phone;

    @Column(name = "id_card_no")
    @ApiModelProperty(value = "身份证号")
    private String idCardNo;

    @Column(name = "type_id")
    @ApiModelProperty(value = "贫困类型")
    private Long typeId;

    @Column(name = "period_id")
    @ApiModelProperty(value = "参加培训期次ID")
    private Long periodId;

    @ManyToOne
    @JoinColumn(name = "period_id", referencedColumnName = "period_id", insertable = false, updatable = false)
    @ApiModelProperty(value = "参加培训期次")
    private Period period;

    @Column(name = "is_pass")
    @ApiModelProperty(value = "是否通过培训测试")
    private Boolean isPass;

    @Column(name = "is_satisfy")
    @ApiModelProperty(value = "是否满意")
    private Boolean isSatisfy;

    @Column(name = "is_worked")
    @ApiModelProperty(value = "是否已就业")
    private Boolean isWorked;

    @Column(name = "enabled")
    @ApiModelProperty(value = "状态")
    private Boolean enabled;

    @Column(name = "work_unit")
    @ApiModelProperty(value = "工作单位")
    private String workUnit;

    @ManyToOne
    @JoinColumn(name = "ref_teacher_id")
    @ApiModelProperty(value = "帮扶教师")
    private Teacher refTeacher;

    @Column(name = "ref_teacher_name")
    @ApiModelProperty(value = "帮扶教师姓名")
    private String refTeacherName;

    public void copy(Student source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
